﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CheckPolicy : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Page.Validate("search");
        if (Page.IsValid)
        {
            Policy poli = new Policy();
            PolicyBll polibll = new PolicyBll();
            if (TextBoxSearch.Text == "") return;
            poli = polibll.getPolicyById(Convert.ToInt32(TextBoxSearch.Text));
            InsuranceTypeLabel.Text = poli.InsuranceType;
            PolicyValueLabel.Text = poli.PolicyValue.ToString();
            PeriodLabel.Text = poli.Period;
            ContractDateLabel.Text = poli.ContractDate.ToString();
            PaymentFeeLabel.Text = poli.Premium.ToString();
            poli.status();
            if (poli.Paid)
            {
                LabelStatus.Text = "Paid";
            }
            else LabelStatus.Text = "Not Paid";
            Panel1.Visible = true;
        }
    }
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        //Label policyvalue = e.Item.FindControl("PolicyValueLabel") as Label;
        //Label period = e.Item.FindControl("PeriodLabel") as Label;
        //Label premium = e.Item.FindControl("PremiumLabel") as Label;
        //Label contractdate = e.Item.FindControl("ContractDateLabel") as Label;
        //Label paymentdatelabel = e.Item.FindControl("PaymentDateLabel") as Label;
        //Label paymentfeelabel = e.Item.FindControl("PaymentFeeLabel") as Label;
        //Policy policy = new Policy(0, 0, "", Convert.ToInt32(policyvalue.Text), period.Text, float.Parse(premium.Text), Convert.ToDateTime(contractdate.Text),true);
        //DateTime dt = policy.paymentDate();
        //paymentdatelabel.Text = dt.ToLongDateString();
        //paymentfeelabel.Text = policy.paymentFee().ToString();
        //contractdate.Text = Convert.ToDateTime(contractdate.Text).ToLongDateString();
    }
}